<?php

namespace App\Http\Requests\Order;

use App\Http\Requests\ApiRequest;
use App\Models\Products\Review;
use Illuminate\Validation\Rule;

/**
 * @property string order_product_id
 * @property string rating
 * @property string text
 * @property array images
 */
class ReviewStoreRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'order_product_id' => 'required|int|min:1',
            'rating'           => ['required', 'int', Rule::in(Review::REVIEW_RATING_MAP)],
            'text'             => 'required|string',
            'images'           => 'nullable|array|max:5',
            'images.*'         => 'nullable|string|url',
        ];
    }
}
